-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Refactoring of CometError/SparkError #655
Conversation
@Blizzara @advancedxy fyi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
native/spark-expr/src/error.rs
Outdated
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::ArithmeticOverflow { from_type } => | ||
write!(f, "[ARITHMETIC_OVERFLOW] {from_type} overflow. If necessary set \"spark.sql.ansi.enabled\" to \"false\" to bypass this error."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we keep the earlier comment, i.e. // Note that this message format is based on Spark 3.4
?
use std::fmt::{Display, Formatter}; | ||
|
||
#[derive(Debug)] | ||
pub enum SparkError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not specified to expression but also Spark operator. But since we don't have spark-operator crate, it looks okay to have it in spark-expr
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment, others LGTM.
native/spark-expr/src/error.rs
Outdated
impl Display for SparkError { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::ArithmeticOverflow { from_type } => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we leverage the error macro in the previous impl?
#[error("[ARITHMETIC_OVERFLOW] {from_type} overflow. If necessary set \"spark.sql.ansi.enabled\" to \"false\" to bypass this error.")]
Which seems slightly readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason I didn't do this was because I was trying to avoid adding a dependency on thiserror
, but from looking at their documentation it seems like this isn't really an issue because it is just a derive macro. I will make this change.
Which issue does this PR close?
Part of #630
Rationale for this change
These changes are extracted from the larger WIP PR #654 and are a first step to being able to move the
cast
expression to the newspark-expr
crate.What changes are included in this PR?
SparkError
into its own source fileArithmeticOverflow
,CastInvalidValue
,CastOverFlow
, andNumericValueOutOfRange
fromCometError
toSparkError
CometError::Spark(SparkError)
variantHow are these changes tested?
Existing tests